<template>
	<view class="setting">
		<uni-list>
			<uni-list-item title="编辑资料" link :to="'../user/edit?id=' + userId"></uni-list-item>
			<uni-list-item title="帐户与安全" link :to="'../user/security?id=' + userId"></uni-list-item>
			<uni-list-item title="隐私设置" link :to="'../user/privacy?id=' + userId"></uni-list-item>
			<uni-list-item title="给东北土著提意见" link :to="'../user/feedback?id=' + userId"></uni-list-item>
			<uni-list-item title="关于东北土著" link :to="'../user/aboutus'"></uni-list-item>
		</uni-list>
		<view class="button" @click="quitHandle">退出登录</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			userId: ''
		};
	},
	onShow() {
		this.boolLogin()
	},
	onLoad() {
		console.log(getApp().globalData)
		this.userId = getApp().globalData.userInfo.userId;
		this.boolLogin();
	},
	methods: {
		boolLogin(callback){
			let that = this;
			return new Promise((resolve, reject) => {
				that._plugins.boolLogin().then(() => {
					callback && callback()
					resolve()
				}).catch(() => {
					uni.navigateTo({
						url:"../login/login"
					});
				})
			})
		},
		quitHandle(){
			['token', 'uid', 'username', 'password', 'userInfo'].forEach(n => {
				getApp().globalData[n] = null;
			});
			uni.setStorageSync('globalData', JSON.stringify(getApp().globalData));
			uni.navigateTo({
				url: '../login/login'
			});
		}
	}
};
</script>

<style lang="less">
.setting {
	color: #333333;
	display: flex;
	flex-direction: column;
	justify-content: center;
	.button {
		border: 2rpx #cccccc solid;
		border-radius: 10rpx;
		text-align: center;
		margin: 60rpx;
		padding: 12rpx 20rpx;
		font-size: 28rpx;
	}
}
</style>
